package cn.wyl.feignclient;
import cn.wyl.Store;
import cn.wyl.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

//工厂方式的 ， 托底类
@Component
public class StoreFeignClientFallbackFactory implements FallbackFactory<StoreFeignClient> {

    //拖地方法 ： throwable，异常
    @Override
    public StoreFeignClient create(Throwable throwable) {
        //返回UserFeignClient 接口的实例
        return new StoreFeignClient() {

            @Override
            public JsonResult add(Store store) {
                //throw new RuntimeException("store服务异常，熔断降级");
                return new JsonResult(false,"被StoreFeignClient熔断了，store添加失败");
            }
        };

    }
}